﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using SuperKnowledgeDatabase2000Client.KennismanagementReference;

namespace SuperKnowledgeDatabase2000Client
{
    /// <summary>
    /// UI logica for CreateCategorie.xaml
    /// </summary>
    public partial class CreateCategorie : Window
    {
        public bool saveAction = true;
        public String categoryName;

        public CreateCategorie()
        {
            InitializeComponent();
        }

        protected override void OnContentRendered(EventArgs e)
        {
            this.Activate();
            base.OnContentRendered(e);
            txt_categorie.Focus();       
        }

        protected void Cancel(object sender, RoutedEventArgs e)
        { 
            this.Close();
        }

        protected void Save(object sender, RoutedEventArgs e)
        {
            if (txt_categorie.Text.Length > 0)
            {
                if (txt_categorie.Text != "Alle" && txt_categorie.Text != "alle" || txt_categorie.Text !="")
                {
                    saveAction = true;
                    categoryName = txt_categorie.Text;
                }
                else
                {
                    MessageBox.Show("'Alle' of 'alle' mag niet gebruikt worden als categorienaam", "Niet toegestaan", MessageBoxButton.OK, MessageBoxImage.Warning);
                }
                this.Close();
            }
        }

        /// <summary>
        /// saves operation, when user pushes the "Enter" button
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void OnKeyDownHandler(object sender, KeyEventArgs e)
        {
            if (e.Key == Key.Enter)
            {
                Save(this, new RoutedEventArgs());
            }
        }
    }
}
